<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * Endereco filter form base class.
 *
 * @package    filters
 * @subpackage Endereco *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseEnderecoFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_usuario'             => new sfWidgetFormDoctrineChoice(array('model' => 'DadosUsuario', 'add_empty' => true)),
      'id_dados_comerciais'    => new sfWidgetFormDoctrineChoice(array('model' => 'DadosComerciais', 'add_empty' => true)),
      'nu_cep'                 => new sfWidgetFormFilterInput(),
      'logradouro'             => new sfWidgetFormFilterInput(),
      'logradouro_numero'      => new sfWidgetFormFilterInput(),
      'logradouro_complemento' => new sfWidgetFormFilterInput(),
      'bairro'                 => new sfWidgetFormFilterInput(),
      'cidade'                 => new sfWidgetFormFilterInput(),
      'sg_uf'                  => new sfWidgetFormFilterInput(),
      'estado'                 => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'id_usuario'             => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DadosUsuario', 'column' => 'id_usuario')),
      'id_dados_comerciais'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DadosComerciais', 'column' => 'id_dados_comerciais')),
      'nu_cep'                 => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'logradouro'             => new sfValidatorPass(array('required' => false)),
      'logradouro_numero'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'logradouro_complemento' => new sfValidatorPass(array('required' => false)),
      'bairro'                 => new sfValidatorPass(array('required' => false)),
      'cidade'                 => new sfValidatorPass(array('required' => false)),
      'sg_uf'                  => new sfValidatorPass(array('required' => false)),
      'estado'                 => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('endereco_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Endereco';
  }

  public function getFields()
  {
    return array(
      'id_endereco'            => 'Number',
      'id_usuario'             => 'ForeignKey',
      'id_dados_comerciais'    => 'ForeignKey',
      'nu_cep'                 => 'Number',
      'logradouro'             => 'Text',
      'logradouro_numero'      => 'Number',
      'logradouro_complemento' => 'Text',
      'bairro'                 => 'Text',
      'cidade'                 => 'Text',
      'sg_uf'                  => 'Text',
      'estado'                 => 'Text',
    );
  }
}